<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-p1KAotb3W9ndluCsqePPYnjRm3c6abdnIjo0tQwYUv83VsbsYd43RuofnFAaDo0E" crossorigin="anonymous">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/css/signin.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="/js/ie-emulation-modes-warning.js"></script>
    <script src="https://fastly.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.33/assets/js/ie-emulation-modes-warning.js"></script>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="form-signin" action="/manager/loginBySMS" method="post" >
    <h2 class="form-signin-heading text-center">请输入电话号码进行短信验证登录</h2>
    <label for="phone" class="sr-only">Your Phone Number</label>
    <input type="text" id="phone" name="phone" class="form-control" placeholder="phone" required autofocus>
    <label for="cacheCode" class="sr-only">Verification Code</label>
    <input type="text" id="cacheCode" name="cacheCode" class="form-control" placeholder="cacheCode" required>
    <span id="getCodeTips"></span>
    <p>
    <p></p>
    </p>

    <dl class="dl-horizontal" >
        <div class="col-md-16 col-md-offset-4">
            <a id="getCode" class="btn btn-lg btn-primary btn-block" role="button" >Get Code</a>
            <a id="codeSignIn" class="btn btn-lg btn-primary btn-block" role="button" >Sign in</a>
            <a class="btn btn-lg btn-primary btn-block"  href="/manager/viewLoginForm" role="button" >Back</a>
        </div>
    </dl>
</div>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="https://fastly.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.33/assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-E5Sj1saJVFNzWWK3YIJB4LEDEEVEGaOdfmCprPDkfWUo+xkb6Ep52Q1TMEtgcFwi" crossorigin="anonymous"></script>

<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="/js/vendor/jquery.min.js"><\/script>')</script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/jquery.jqGrid.min.js"></script>
<script src="/js/grid.locale-en.js"></script>
<script src="/js/vendor/holder.min.js"></script>
<script src="/js/ie10-viewport-bug-workaround.js"></script>



<!--[if !IE]> -->
<script src="/js/jquery-2.1.4.min.js"></script>
<!-- <![endif]-->
<!--[if IE]>
<script src="/js/jquery-1.11.3.min.js"></script>
<![endif]-->
<script type="text/javascript">
    if('ontouchstart' in document.documentElement) document.write("<script src='/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<!-- page specific plugin scripts -->
<script src="/js/bootstrap-datepicker.min.js"></script>
<script src="/js/jquery.jqGrid.min.js"></script>
<script src="/js/grid.locale-en.js"></script>
<!-- ace scripts -->
<script src="/js/ace-elements.min.js"></script>
<script src="/js/ace.min.js"></script>

<script type="text/javascript">
    $(document).ready(function (){
        $('#getCode').on('click',function (){

            let phonenum = $('#phone').val();

            $.ajax({
                type : "get",
                url : "/manager/GetCode",
                data : {
                    "phone":phonenum
                },
                dataType:"text",
                success : function (data){
                    if(data ==='no phone'){
                        $('#getCodeTips').text('手机号未注册！');
                    }else if(data ==='Get Code Success'){
                        $('#getCodeTips').text('验证码发送成功！');
                    }else {
                        $('#getCodeTips').text('验证码发送失败~');
                    }
                }

            });
        });
        $('#codeSignIn').on('click',function (){

            let cacheCode = $('#cacheCode').val();

            $.ajax({
                type : "get",
                url : "/manager/loginBySMS",
                data : {
                    "cacheCode":cacheCode
                },
                dataType:"text",
                success : function (data){
                    if(data ==='Success'){
                        window.location.href = "/catalog/main";
                    }else {
                        $('#getCodeTips').text('验证码输入错误！！');
                    }
                }

            });
        });
    });
</script>

</body>
</html>